/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"57FC142D-4A9C-407B-BF3E-9C5CA7658947",variableType:4}
 */
var desayuno = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"7684CD4E-0069-436D-BD48-88E314E50A86"}
 */
var fOrden = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"0A9335E6-7466-4D54-B1AB-8CA224A7BD00",variableType:4}
 */
var fMenores = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"E7E24922-3A69-425A-AAE8-452F968A16F5",variableType:4}
 */
var fPasajeros = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"AB96C073-4A7A-4C17-8C6B-9C4A1367D99D"}
 */
function reservar(event) {
	globals.gTarifaId			= tarifa_id
	globals.gTipoHabitacionId 	= tipo_habitacion_id
	forms.reserva_3.controller.loadRecords(tipo_habitacion_id)
	forms.reserva_3.onShow(null,null,0)
	globals.show('reserva_3')
}

/**
 * @properties={typeid:24,uuid:"4B31E50C-EF46-4828-8739-AA01E56FA7F6"}
 * @AllowToRunInFind
 */
function mostrarFotos() {
	var $win = application.createWindow('HAB_FOTOS',JSWindow.MODAL_DIALOG)
	$win.undecorated = true
	forms.reserva_2_fotos.controller.find()
	forms.reserva_2_fotos.tipo_habitacion_id = tipo_habitacion_id
	var $cant = forms.reserva_2_fotos.controller.search()
	if ($cant > 0)
		$win.show(forms.reserva_2_fotos)
	else
		globals.DIALOGS.showWarningDialog(i18n.getI18NMessage('hoteleria.aviso'),i18n.getI18NMessage('hoteleria.aviso.noFotos'),'OK')
}

/**
 * Handle changed data.
 *
 * @param {String} oldValue old value
 * @param {String} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"58E4AD47-73B0-44CB-8CC8-5C4CB77FE742"}
 */
function onDataChangeOrden(oldValue, newValue, event) {
	controller.sort(fOrden)
	return true
}

/**
 * Handle changed data.
 *
 * @param {Number} oldValue old value
 * @param {Number} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"CD89307F-E53D-4ABD-8060-E4546030AD05"}
 */
function onDataChangeMoneda(oldValue, newValue, event) {
	if (newValue == 2)
	{
		//MUESTRO DOLARES
		var $dolar = true
	}
	else
	{
		//MUESTRO NACIONAL
		var $dolar = false
	}
	
	for (var i = 1 ; i <= forms.reserva_2.elements.tab_resultados.getMaxTabIndex() ; i++)
	{
		var $idx = forms.reserva_2.elements.tab_resultados.getTabFormNameAt(i)
		forms[$idx].elements.fld_precio.visible 		= !$dolar
		forms[$idx].elements.fld_precio_dls.visible 	= $dolar
		forms[$idx].elements.fld_precio_real.visible 	= !$dolar
		forms[$idx].elements.fld_precio_real_dls.visible = $dolar
	}
	return true
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7A30F75B-F4A9-4982-8641-5C9D1CC6F772"}
 */
function onShow(firstShow, event) {
	if (globals.gMoneda == 2)
	{
		//MUESTRO DOLARES
		var $dolar = true
	}
	else
	{
		//MUESTRO NACIONAL
		var $dolar = false
	}
	elements.fld_precio.visible 		= !$dolar
	elements.fld_precio_dls.visible 	= $dolar
	elements.fld_precio_real.visible 	= !$dolar
	elements.fld_precio_real_dls.visible = $dolar
}

/**
 * Called before the form component is rendered.
 *
 * @param {JSRenderEvent} event the render event
 *
 * @properties={typeid:24,uuid:"37804DAD-505C-44F5-B641-B9773435A67F"}
 */
function onRenderDescuento(event) {
	var $rcd = event.getRecord()
	if ($rcd.descuento == null)
	{
		event.getRenderable().visible = false
	}
	else
	{
		event.getRenderable().visible = true
	}
}

/**
 * Called before the form component is rendered.
 *
 * @param {JSRenderEvent} event the render event
 *
 * @properties={typeid:24,uuid:"6B3CD608-4034-4D0E-87B1-C146BAACD43D"}
 */
function onRenderOferta(event) {
	var $rcd = event.getRecord()
	if ($rcd.mensaje == null)
	{
		event.getRenderable().visible = false
	}
	else
	{
		event.getRenderable().visible = true
	}
}
